package com.enjoyor.soa.traffic.rest.tsms.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.enjoyor.soa.traffic.frame.annotation.Auth;
import com.enjoyor.soa.traffic.util.helper.ResultHelper;
import com.enjoyor.soa.traffic.util.helper.TimeHelper;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Auth
@RestController
@RequestMapping({ "/date" })
@Api("服务器时间接口")
@CrossOrigin
public class DateServiceController {

	@GetMapping(value = { "getServiceTimeReal" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("查询服务器时间信息")
	//@ApiImplicitParam(name = "tacticsId", value = "报警策略编号", paramType = "query", required = true, dataType = "String")
	public ResultPojo getServiceTimeReal(
			//@RequestParam(defaultValue = "", value = "tacticsId", required = false) String tacticsId,
			HttpServletRequest request) {
		Date newDate = new Date();
		int weekNum = TimeHelper.dayOfWeek(newDate);
		String weekName = "未知";
		if(weekNum == 1) {
			weekName = "星期一";
		}else if(weekNum == 2) {
			weekName = "星期二";
		}else if(weekNum == 3) {
			weekName = "星期三";
		}else if(weekNum == 4) {
			weekName = "星期四";
		}else if(weekNum == 5) {
			weekName = "星期五";
		}else if(weekNum == 6) {
			weekName = "星期六";
		}else if(weekNum == 0 || weekNum == 7) {
			weekName = "星期日";
		}
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("time", TimeHelper.dateToLongString(newDate));
		resultMap.put("week", weekName);
		return ResultHelper.getResult(resultMap);
	}
}
